<div class="fsh-pop">
    <div id="add_form" class="layui-form">
        <input type="hidden" name="id" value="<%=id%>">
        <div class="layui-form-item">
            <label class="layui-form-label">LOGO</label>
            <div class="layui-input-block">
                <img class="layui-upload-img" id="demo1" src="<%=logo%>">
                <input type="hidden" id="logo" name="logo" value="<%=logo%>"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>学校名称</label>
            <div class="layui-input-block">
                <input type="text" name="schoolName" lay-verify="required" placeholder="请输入关键字" class="layui-input" value="<%=schoolName%>">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>所属部门</label>
            <div class="layui-input-block">
                <input type="text" name="department" lay-verify="required" placeholder="请输入关键字" class="layui-input" value="<%=department%>">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>编码</label>
            <div class="layui-input-block">
                <input name="code" maxlength="20" lay-verify="required" placeholder="请输入内容" class="layui-input" value="<%=code%>">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>所属城市</label>
            <div class="layui-input-block">
                <input name="location" maxlength="20" lay-verify="required" placeholder="请输入内容" class="layui-input" value="<%=location%>">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>类别</label>
            <div class="layui-input-block">
                <input name="level" maxlength="20" lay-verify="required" placeholder="请输入内容" class="layui-input" value="<%=level%>">
            </div>
        </div>

    </div>

</div>
<style type="text/css">
    #demo1 {
        width: 100px;
        height: 100px;
        border: 1px solid #e3e3e3;
    }
</style>
<script type="text/javascript">


    layui.use(['upload', 'form'], function () {
        var upload = layui.upload;
        var form = layui.form;

        //执行实例
        var uploadInst = upload.render({
            elem: '#demo1'
            , url: context + '/api/fileupload/add'
            , field: 'attach'
            , done: function (res) {
                //如果上传失败
                if (res.success) {
                    $('#demo1').attr('src', res.link);
                    $('#logo').val(res.link);
                } else {
                    layui.layer.msg('上传失败');
                }
                //上传成功
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });

</script>
